package com.billdowney.util.encrypt;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import org.apache.commons.codec.binary.Hex;

public class SHAUtil {

	//字符串进行SHA1加密
	public static String strToSHA1(String str) {
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("SHA");
			md.update(str.getBytes());
		} catch (NoSuchAlgorithmException e) {
			e.printStackTrace();
			return "";
		}
		return Hex.encodeHexString(md.digest());
	}
	
}
